﻿import mx.utils.Delegate;
class ui.shapes extends base.base
{
	static var topLeftx:Number;
	static var topLefty:Number;
	static var topRightx:Number;
	static var topRighty:Number;
	static var bottomRightx:Number;
	static var bottomRighty:Number;
	static var bottomLeftx:Number;
	static var bottomLefty:Number;
	static var interval:Number;
	static var clipLoader:MovieClipLoader = new MovieClipLoader ();
	//
	//
	//////////////////////// SHAPES
	//
	//
	public static function createShape (theType:String)
	{
		var theParams:Array = arguments.splice (1, arguments.length - 1);
		switch (theType)
		{
			//
			//	// Rectangle
			//
		case "rectangle" :
			//mc, left, top, recWidth, recHeight, cornerRadius, fillColour, fillAlpha, isStatic, haveLine, lineWidth, lineColour
			var mc:MovieClip = theParams[0];
			var left:Number = theParams[1];
			var top:Number = theParams[2];
			var recWidth:Number = theParams[3];
			var recHeight:Number = theParams[4];
			var cornerRadius:Number = theParams[5];
			var fillColour:Number = theParams[6];
			var fillAlpha:Number = theParams[7];
			var isStatic:Boolean = theParams[8];
			var haveLine:Boolean = theParams[9];
			var lineWidth:Number
			var lineColour:Number
			if (haveLine == true)
			{
				lineWidth = theParams[10];
				lineColour = theParams[11];
			}
			//
			//set some stuff
			//
			topLeftx = left;
			topLefty = top;
			topRightx = left + recWidth;
			topRighty = top;
			bottomRightx = left + recWidth;
			bottomRighty = top + recHeight;
			bottomLeftx = left;
			bottomLefty = top + recHeight;
			//
			//begin the drawing
			//
			if (isStatic == false)
			{
				mc.clear ();
			}
			mc.beginFill (fillColour, fillAlpha);
			mc.moveTo (topLeftx + cornerRadius, topLefty);
			//line style
			if (haveLine == true)
			{
				mc.lineStyle (lineWidth, lineColour);
			}
			//start drawing
			mc.lineTo (topRightx - cornerRadius, topRighty);
			mc.curveTo (topRightx, top, topRightx, topRighty + cornerRadius);
			mc.lineTo (topRightx, topRighty + cornerRadius);
			mc.lineTo (bottomRightx, bottomRighty - cornerRadius);
			mc.curveTo (bottomRightx, bottomRighty, bottomRightx - cornerRadius, bottomRighty);
			mc.lineTo (bottomRightx - cornerRadius, bottomRighty);
			mc.lineTo (bottomLeftx + cornerRadius, bottomLefty);
			mc.curveTo (bottomLeftx, bottomLefty, bottomLeftx, bottomLefty - cornerRadius);
			mc.lineTo (bottomLeftx, bottomLefty - cornerRadius);
			mc.lineTo (topLeftx, topLefty + cornerRadius);
			mc.curveTo (topLeftx, topLefty, topLeftx + cornerRadius, topLefty);
			mc.lineTo (topLeftx + cornerRadius, topLefty);
			mc.endFill ();
			break;
			//
			//	// CIRCLE
			//
		case "circle" :
			//mc, radius, fillColourfillAlpha, x1, y1, doLine, lineWidth, lineColour
			var mc:MovieClip = theParams[0];
			var radius:Number = theParams[1];
			var fillColour:Number = theParams[2];
			var fillAlpha:Number = theParams[3];
			var x1:Number = theParams[4];
			var y1:Number = theParams[5];
			var doLine:Boolean = theParams[6];
			var lineWidth:Number
			var lineColour:Number
			if (doLine == true)
			{
				lineWidth = theParams[7];
				lineColour = theParams[8];
			}
			//
			//set some stuff
			//
			var x:Number = x1;
			var y:Number = y1;
			//
			//begin Drawing
			//
			mc.beginFill (fillColour, fillAlpha);
			mc.moveTo (x + radius, y);
			if (doLine == true)
			{
				mc.lineStyle (lineWidth, lineColour);
			}
			mc.curveTo (radius + x, Math.tan (Math.PI / 8) * radius + y, Math.sin (Math.PI / 4) * radius + x, Math.sin (Math.PI / 4) * radius + y);
			mc.curveTo (Math.tan (Math.PI / 8) * radius + x, radius + y, x, radius + y);
			mc.curveTo (-Math.tan (Math.PI / 8) * radius + x, radius + y, -Math.sin (Math.PI / 4) * radius + x, Math.sin (Math.PI / 4) * radius + y);
			mc.curveTo (-radius + x, Math.tan (Math.PI / 8) * radius + y, -radius + x, y);
			mc.curveTo (-radius + x, -Math.tan (Math.PI / 8) * radius + y, -Math.sin (Math.PI / 4) * radius + x, -Math.sin (Math.PI / 4) * radius + y);
			mc.curveTo (-Math.tan (Math.PI / 8) * radius + x, -radius + y, x, -radius + y);
			mc.curveTo (Math.tan (Math.PI / 8) * radius + x, -radius + y, Math.sin (Math.PI / 4) * radius + x, -Math.sin (Math.PI / 4) * radius + y);
			mc.curveTo (radius + x, -Math.tan (Math.PI / 8) * radius + y, radius + x, y);
			mc.endFill ();
			break;
			//
			//	// LINE
			//
		case "line" :
			//mc
			var mc:MovieClip = theParams[0];
			var x1:Number = theParams[1];
			var y1:Number = theParams[2];
			var x2:Number = theParams[3];
			var y2:Number = theParams[4];
			var lineWidth:Number = theParams[5];
			var lineColour:Number = theParams[6];
			//
			//begin Drawing
			//
			mc.moveTo (x1, y1);
			mc.lineStyle (lineWidth, lineColour);
			mc.lineTo (x2, y2);
			break;
		}
	}
}
